{% extends "ProjetUserBundle::layout.html.twig" %}

{% block title %}
	Accueil - {{ parent() }}
{% endblock %}

{% block fos_user_content %}

<div class="alert alert-warning"><h2>Messagerie</h2></div>
{% include "ProjetUserBundle:Message:outils.html.twig" %}

<div id="messages-box">
{% if entities %}
<table class="table">
    <thead>
        <tr>
            <th>Sujet</th>
            <th>Avec</th>
            <th>Commencé le</th>
            <th>Actions</th>
        </tr>
    </thead>
{% else %}
<div class="alert alert-danger"><h2>Vous n'avez pas de messages !</h2></div>    
{% endif %}
    <tbody>
    {% for entity in entities %}
        <tr>
            <td>{{ entity.sujet }}</td>
            <td>{{ app.user == entity.user ? entity.destinataire : entity.user }}</td>
            <td>{% if entity.createdat %}{{ entity.createdat|date('Y-m-d à H:i:s') }}{% endif%}</td>
            <td>
                <ul>
                    <li>
                        <a href="{{ path('message_show', { 'id': entity.id }) }}">show</a>
                    </li>
                </ul>
            </td>
        </tr>
    {% endfor %}
    </tbody>
</table>
</div>
{% endblock %}